<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            padding: 0;
            margin: 0;
            box-sizing: border-box;
        }

        div {
            width: 300px;
            height: 300px;
            background: black;
            margin: auto;
            border: 20px solid black;
            color: white;
        }
    </style>
</head>

<body>
    <div>
        鼠标移入改变样式，鼠标移出恢复
    </div>
</body>

</html>
<script>
    let div = document.querySelector('div')
    div.onmouseover = function () {
        div.style.border = '20px solid red'
        div.style.background = 'white'
        div.style.color = 'red'
    }
    div.onmouseout = function () {
        div.style.border = '20px solid black'
        div.style.background = 'black'
        div.style.color = 'white'
    }
</script>